home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / DropInfo ƒ / DI⁄P / DIUtils.p < prev    next >
Encoding:
Text File  |  1991-12-22  |  4.0 KB  |  167 lines  |  [TEXT/MPS ]

  1. {******************************************************************************
  2. **
  3. **  Project Name:    DropInfo
  4. **     File Name:    DIUtils.p
  5. **
  6. **   Description:    Generic utility routines used by DropInfo
  7. **
  8. *******************************************************************************
  9. **                       A U T H O R   I D E N T I T Y
  10. *******************************************************************************
  11. **
  12. **    Initials    Name
  13. **    --------    -----------------------------------------------
  14. **    SCS            Stephan Somogyi
  15. **    LDR            Leonard Rosenthol
  16. **
  17. *******************************************************************************
  18. **                      R E V I S I O N   H I S T O R Y
  19. *******************************************************************************
  20. **
  21. **      Date        Time    Author    Description
  22. **    --------    -----    ------    ---------------------------------------------
  23. **    12/22/91            LDR        Ported to Pascal
  24. **    29.22.91            SCS        Original Version scavenged from MyMacStuff parts
  25. **
  26. ******************************************************************************}
  27. UNIT DIUtils;
  28. INTERFACE
  29.  
  30. {$IFC THINK_Pascal}
  31.     USES
  32.         Aliases, AppleEvents, PPCToolbox, Processes, Script, DSGlobals;    {just the DropShell files}
  33. {$ELSEC}
  34.     USES
  35.     { First load standard interface files}
  36.         MemTypes, QuickDraw, 
  37.  
  38.     { Now include the stuff from OSIntf }
  39.         OSIntf, 
  40.  
  41.     { Now Include the stuff from ToolIntf.p }
  42.         ToolIntf, Packages, GestaltEqu, 
  43.  
  44.     { Then any OTHER Toolbox interfaces... }
  45.         Files, Aliases, AppleEvents, PPCToolbox, Processes, 
  46.  
  47.     { And finally any files from DropShell }
  48.         DSGlobals;
  49. {$ENDC THINK_Pascal}
  50.  
  51. PROCEDURE FlashItem(pDial:DialogPtr; pItem: integer);
  52.  
  53. PROCEDURE DisEnAble(pDial:DialogPtr; pItem: integer; on: Boolean);
  54. PROCEDURE CheckBox(pDial:DialogPtr; pItem: integer; on: Boolean);
  55.  
  56. PROCEDURE GetTxtItem(pDial:DialogPtr; pItem: integer; VAR txt: Str255);
  57. PROCEDURE SetTxtItem(pDial:DialogPtr; pItem: integer; txt: Str255);
  58.  
  59. PROCEDURE DefBut(dptr: DialogPtr);
  60.  
  61. IMPLEMENTATION
  62.  
  63. {
  64.     Flashes an item, in DropInfo's case a button, briefly. Used to show the
  65.     effect of a kbd-shortcut.
  66. }
  67. PROCEDURE FlashItem(pDial:DialogPtr; pItem: integer);
  68. VAR
  69.     lType: integer;
  70.     lHndl: Handle;
  71.     lBox: Rect;
  72.     lDummy: longint;
  73. BEGIN
  74.     GetDItem(pDial, pItem, lType, lHndl, lBox);
  75.     IF (ControlHandle(lHndl)^^.contrlHilite <> 255) THEN
  76.     BEGIN
  77.         HiliteControl(ControlHandle(lHndl), 1);
  78.         Delay(8, lDummy);
  79.         HiliteControl(ControlHandle(lHndl), 0);
  80.     END;
  81. END;
  82.  
  83.  
  84. {
  85.     Disables or enables a item in a dialog box depending on the state of the
  86.     parameter "on".
  87. }
  88. PROCEDURE DisEnAble(pDial:DialogPtr; pItem: integer; on: Boolean);
  89. VAR
  90.     lType: integer;
  91.     lHndl: Handle;
  92.     lBox: Rect;
  93. BEGIN
  94.     GetDItem(pDial, pItem, lType, lHndl, lBox);
  95.     IF (on) THEN
  96.         HiliteControl(ControlHandle(lHndl), 0)
  97.     ELSE
  98.         HiliteControl(ControlHandle(lHndl), 255);
  99. END;
  100.  
  101.  
  102. {
  103.     Checks or unchecks either a checkbox or a radio button depending on the
  104.     state of the parameter "on".
  105. }
  106. PROCEDURE CheckBox(pDial:DialogPtr; pItem: integer; on: Boolean);
  107. VAR
  108.     lType: integer;
  109.     lHndl: Handle;
  110.     lBox: Rect;
  111. BEGIN
  112.     GetDItem(pDial, pItem, lType, lHndl, lBox);
  113.     IF (on) THEN
  114.         SetCtlValue(ControlHandle(lHndl), 1)
  115.     ELSE
  116.         SetCtlValue(ControlHandle(lHndl), 0);
  117. END;
  118.  
  119.  
  120. { Gets the contents of the dialog text item specified }
  121. PROCEDURE GetTxtItem(pDial:DialogPtr; pItem: integer; VAR txt: Str255);
  122. VAR
  123.     lType: integer;
  124.     lHndl: Handle;
  125.     lBox: Rect;
  126. BEGIN
  127.     GetDItem(pDial, pItem, lType, lHndl, lBox);
  128.     GetIText(lHndl, txt);
  129. END;
  130.  
  131.  
  132. {    Sets the contents of the dialog text item specified }
  133. PROCEDURE SetTxtItem(pDial:DialogPtr; pItem: integer; txt: Str255);
  134. VAR
  135.     lType: integer;
  136.     lHndl: Handle;
  137.     lBox: Rect;
  138. BEGIN
  139.     GetDItem(pDial, pItem, lType, lHndl, lBox);
  140.     SetIText(lHndl, txt);
  141. END;
  142.  
  143.  
  144. {    Creates the standard outline around a dialog's default item }
  145. PROCEDURE DefBut(dptr: DialogPtr);
  146. VAR
  147.     lType: integer;
  148.     lHndl: Handle;
  149.     lBox: Rect;
  150.     oldPen: PenState;
  151.     oldPort: GrafPtr;
  152. BEGIN
  153.     GetPenState(oldPen);
  154.     GetPort(oldPort);
  155.     SetPort(dptr);
  156.     
  157.     GetDItem(dptr, DialogPeek(dptr)^.aDefItem, lType, lHndl, lBox);
  158.     InsetRect(lBox, -4, -4);
  159.     PenSize(3, 3);
  160.     FrameRoundRect(lBox, 16, 16);
  161.     
  162.     SetPort(oldPort);
  163.     SetPenState(oldPen);
  164. END;
  165.  
  166. END.
  167.